package com.zfjt.controller;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSON;
import com.zfjt.constants.InterfaceDefinition;
import com.zfjt.entity.ClientmessageBean;
import com.zfjt.entity.ReturnBean;
import com.zfjt.packnum.PackNum00016;
import com.zfjt.service.ClientmessageBeanService;

/**
 * 续传订单接口
 * @author xk
 * @version 1.0
 * @date 2017年3月25日
 */
@Controller
public class ContinueOrderController {
	
	private ReturnBean mReturn;
	
	@Autowired
	private ClientmessageBeanService mClientMessage;
	
	private Map<String, String> fhdata; 
	
	@RequestMapping(value="00016")
	@ResponseBody
	public ReturnBean AddBrabch(HttpSession hseesion,HttpServletRequest request){
		mReturn = new ReturnBean();
		fhdata = new HashMap<>();
		//传过来的参数
		String data =  (String) hseesion.getAttribute("data");
		PackNum00016 num00016 = JSON.parseObject(data,PackNum00016.class); 	
		ClientmessageBean mdata = mClientMessage.selectByPrimaryKey((short) Integer.parseInt(num00016.getId()));
		if (data.equals(InterfaceDefinition.IStatusCode.TOKEN_FAILURE)) {//校验码错误
			mReturn.setCode("001");
			mReturn.setPortnum("00016");
			fhdata.put("error", "TOKEN_ERROR");
			mReturn.setData(JSON.toJSONString(fhdata));
		}else{
			//查询该订单传的完成状况
			String str1 = mClientMessage.selectByPrimaryKey((short) Integer.parseInt(num00016.getId())).getIsaccomplish();
			//订单类型
			String str2 = mClientMessage.selectByPrimaryKey((short) Integer.parseInt(num00016.getId())).getProduct();
			//订单类型时期
			String str3 = mClientMessage.selectByPrimaryKey((short) Integer.parseInt(num00016.getId())).getGenre();
			mReturn.setCode("000");
			fhdata.put("Isaccomplish", str1);
			fhdata.put("product", str2);
			fhdata.put("genre", str3);
			mReturn.setData(JSON.toJSONString(fhdata));
			mReturn.setPortnum("00016");
		}
		return mReturn;
	}
}
